<html>
<head><meta charset="utf-8"><title>event filter / level of detail · t-compiler/wg-self-profile · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/index.html">t-compiler/wg-self-profile</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/event.20filter.20.2F.20level.20of.20detail.html">event filter / level of detail</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="162989448"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/event%20filter%20/%20level%20of%20detail/near/162989448" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mw <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/event.20filter.20.2F.20level.20of.20detail.html#162989448">(Apr 10 2019 at 09:47)</a>:</h4>
<p>I think it makes sense to allow some control over what events the compiler records in order to keep profiling overhead as low as possible.</p>



<a name="162989513"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/event%20filter%20/%20level%20of%20detail/near/162989513" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mw <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/event.20filter.20.2F.20level.20of.20detail.html#162989513">(Apr 10 2019 at 09:48)</a>:</h4>
<p>one obvious example is query keys. recording those will have quite a bit of overhead.</p>



<a name="162989664"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/event%20filter%20/%20level%20of%20detail/near/162989664" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mw <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/event.20filter.20.2F.20level.20of.20detail.html#162989664">(Apr 10 2019 at 09:51)</a>:</h4>
<p>but another example that is already relevant in the current version is query cache hits. As <span class="user-mention" data-user-id="125250">@Wesley Wiser</span> mentioned <a href="#narrow/stream/187831-t-compiler.2Fwg-self-profile/topic/measureme.20performance/near/162136966" title="#narrow/stream/187831-t-compiler.2Fwg-self-profile/topic/measureme.20performance/near/162136966">here</a> they make up a huge portion of events overall, but for most kinds of analysis they are not needed.</p>



<a name="162996055"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/event%20filter%20/%20level%20of%20detail/near/162996055" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/event.20filter.20.2F.20level.20of.20detail.html#162996055">(Apr 10 2019 at 11:39)</a>:</h4>
<p>Yeah, I think we should offer some kind of control here. One option would be to allow complete control over the event types that will be captured a la <code>-Z profiler-events=query,activity,incremental,etc</code>. Another (better?) option would be some kind of "slider" which offers less control but doesn't require as much knowledge to use: <code>-Z profiler-setting={fast|normal|detailed}</code>.</p>



<a name="162997344"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/event%20filter%20/%20level%20of%20detail/near/162997344" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mw <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/event.20filter.20.2F.20level.20of.20detail.html#162997344">(Apr 10 2019 at 11:56)</a>:</h4>
<p>we could do both where <code>fast</code>, <code>normal</code>, <code>detailed</code> just map to a defined set of actual event-types</p>



<a name="162997369"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/event%20filter%20/%20level%20of%20detail/near/162997369" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mw <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/event.20filter.20.2F.20level.20of.20detail.html#162997369">(Apr 10 2019 at 11:57)</a>:</h4>
<p>e.g. <code>-Z profiler-events=query,activity</code> is exactly the same as <code>-Z profiler-events=fast</code></p>



<a name="162997392"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/event%20filter%20/%20level%20of%20detail/near/162997392" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mw <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/event.20filter.20.2F.20level.20of.20detail.html#162997392">(Apr 10 2019 at 11:58)</a>:</h4>
<p>we'd have to decide what happens if one does <code>-Z profiler-events=fast,incremental</code></p>



<a name="162997453"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/event%20filter%20/%20level%20of%20detail/near/162997453" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mw <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/event.20filter.20.2F.20level.20of.20detail.html#162997453">(Apr 10 2019 at 11:58)</a>:</h4>
<p>creating the union of all given sets would be a straightforward option</p>



<a name="162997458"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/event%20filter%20/%20level%20of%20detail/near/162997458" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/event.20filter.20.2F.20level.20of.20detail.html#162997458">(Apr 10 2019 at 11:59)</a>:</h4>
<p>"Adding" them together makes sense to me</p>



<a name="162997461"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/event%20filter%20/%20level%20of%20detail/near/162997461" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/event.20filter.20.2F.20level.20of.20detail.html#162997461">(Apr 10 2019 at 11:59)</a>:</h4>
<p>Yeah</p>



<a name="162997563"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/event%20filter%20/%20level%20of%20detail/near/162997563" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/event.20filter.20.2F.20level.20of.20detail.html#162997563">(Apr 10 2019 at 12:00)</a>:</h4>
<p>(btw, can I get you to sign off on <a href="https://github.com/rust-lang/measureme/pull/21" target="_blank" title="https://github.com/rust-lang/measureme/pull/21">https://github.com/rust-lang/measureme/pull/21</a> which bumps the version number and adds some missing Cargo.toml fields?)</p>



<a name="162997597"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/event%20filter%20/%20level%20of%20detail/near/162997597" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/event.20filter.20.2F.20level.20of.20detail.html#162997597">(Apr 10 2019 at 12:01)</a>:</h4>
<p><span class="user-mention" data-user-id="125250">@Wesley Wiser</span> signed off</p>



<a name="162997606"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/event%20filter%20/%20level%20of%20detail/near/162997606" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/event.20filter.20.2F.20level.20of.20detail.html#162997606">(Apr 10 2019 at 12:01)</a>:</h4>
<p>Thanks <span aria-label="smile" class="emoji emoji-263a" role="img" title="smile">:smile:</span></p>



<a name="162997609"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/event%20filter%20/%20level%20of%20detail/near/162997609" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mw <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/event.20filter.20.2F.20level.20of.20detail.html#162997609">(Apr 10 2019 at 12:01)</a>:</h4>
<p>merged</p>



<a name="163096069"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/event%20filter%20/%20level%20of%20detail/near/163096069" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mw <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/event.20filter.20.2F.20level.20of.20detail.html#163096069">(Apr 11 2019 at 12:53)</a>:</h4>
<p>here is a thought on the implementation: it would be good the filter mechanism could also take care of the case where the profiler is completely disabled.</p>



<a name="163096193"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/event%20filter%20/%20level%20of%20detail/near/163096193" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mw <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/event.20filter.20.2F.20level.20of.20detail.html#163096193">(Apr 11 2019 at 12:54)</a>:</h4>
<p>that is, instead of storing the profiler as <code>Option&lt;Arc&lt;SelfProfiler&gt;&gt;</code> it would something like <code>SelfProfiler { filter_mask: FilterBitFlags, Arc&lt;SelfProfilerData&gt; }</code></p>



<a name="163096206"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/event%20filter%20/%20level%20of%20detail/near/163096206" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mw <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/event.20filter.20.2F.20level.20of.20detail.html#163096206">(Apr 11 2019 at 12:54)</a>:</h4>
<p>where <code>filter_mask</code> would be all zeros for the disabled-case</p>



<a name="163096274"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/event%20filter%20/%20level%20of%20detail/near/163096274" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mw <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/event.20filter.20.2F.20level.20of.20detail.html#163096274">(Apr 11 2019 at 12:55)</a>:</h4>
<p>that way we would avoid checking twice whether we should record an event</p>



<a name="163096534"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/event%20filter%20/%20level%20of%20detail/near/163096534" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mw <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/event.20filter.20.2F.20level.20of.20detail.html#163096534">(Apr 11 2019 at 12:59)</a>:</h4>
<p>in order to implement this we would need to be able to create a <code>Profiler</code> "null object", which is simple for the <code>MmapSerializationSink</code> (allocate the memory maps as usual, just don't write anything to disk at the end) but trickier for the <code>FileSerializationSink</code> because that expects to create the file on disk immediately</p>



<a name="163097340"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/event%20filter%20/%20level%20of%20detail/near/163097340" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/event.20filter.20.2F.20level.20of.20detail.html#163097340">(Apr 11 2019 at 13:08)</a>:</h4>
<p>On *nix, perhaps <code>FileSerializationSink</code> could write to <code>/dev/null</code>?</p>



<a name="163097368"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/event%20filter%20/%20level%20of%20detail/near/163097368" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/event.20filter.20.2F.20level.20of.20detail.html#163097368">(Apr 11 2019 at 13:09)</a>:</h4>
<p>I believe Windows has a <code>NUL</code> device as well</p>



<a name="163097582"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/event%20filter%20/%20level%20of%20detail/near/163097582" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mw <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/event.20filter.20.2F.20level.20of.20detail.html#163097582">(Apr 11 2019 at 13:11)</a>:</h4>
<p>Yes, I've thought of <code>/dev/null</code>. If Windows has an equivalent then that would work</p>



<a name="163097694"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/event%20filter%20/%20level%20of%20detail/near/163097694" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/event.20filter.20.2F.20level.20of.20detail.html#163097694">(Apr 11 2019 at 13:13)</a>:</h4>
<p><a href="https://stackoverflow.com/questions/313111/is-there-a-dev-null-on-windows" target="_blank" title="https://stackoverflow.com/questions/313111/is-there-a-dev-null-on-windows">https://stackoverflow.com/questions/313111/is-there-a-dev-null-on-windows</a></p>



<a name="163098195"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/event%20filter%20/%20level%20of%20detail/near/163098195" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mw <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/event.20filter.20.2F.20level.20of.20detail.html#163098195">(Apr 11 2019 at 13:19)</a>:</h4>
<p>OK, this works on Linux: <code>let _file = std::fs::File::create("/dev/null").unwrap();</code></p>



<a name="163098207"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/event%20filter%20/%20level%20of%20detail/near/163098207" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mw <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/event.20filter.20.2F.20level.20of.20detail.html#163098207">(Apr 11 2019 at 13:19)</a>:</h4>
<p>i.e. there's no error reported.</p>



<a name="163098518"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/event%20filter%20/%20level%20of%20detail/near/163098518" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mw <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/event.20filter.20.2F.20level.20of.20detail.html#163098518">(Apr 11 2019 at 13:24)</a>:</h4>
<p><code>libstd</code> seems to use <code>Path::new("NUL")</code>: <a href="https://github.com/rust-lang/rust/blob/ee1474acc43fbf657b0fc910c139cf63cef34dc8/src/libstd/sys/windows/process.rs#L284-L301" target="_blank" title="https://github.com/rust-lang/rust/blob/ee1474acc43fbf657b0fc910c139cf63cef34dc8/src/libstd/sys/windows/process.rs#L284-L301">https://github.com/rust-lang/rust/blob/ee1474acc43fbf657b0fc910c139cf63cef34dc8/src/libstd/sys/windows/process.rs#L284-L301</a></p>



<a name="163099503"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/event%20filter%20/%20level%20of%20detail/near/163099503" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/event.20filter.20.2F.20level.20of.20detail.html#163099503">(Apr 11 2019 at 13:35)</a>:</h4>
<p>Hm, so one concern with just writing to /dev/null is that we're still paying some cost for the event recording</p>



<a name="163099568"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/event%20filter%20/%20level%20of%20detail/near/163099568" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/event.20filter.20.2F.20level.20of.20detail.html#163099568">(Apr 11 2019 at 13:36)</a>:</h4>
<p>Unless I misunderstood</p>



<a name="163099838"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/event%20filter%20/%20level%20of%20detail/near/163099838" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/event.20filter.20.2F.20level.20of.20detail.html#163099838">(Apr 11 2019 at 13:39)</a>:</h4>
<p>I think <span class="user-mention" data-user-id="124287">@mw</span> is suggesting that when the profiler is disabled, that state will be the same as manually disabling all of the event types. So no events will actually be recorded. However, the <code>FileSerializationSink</code> creates its profile files when it is constructed. We can resolve that when the profiler is disabled by having it "write" to <code>/dev/null</code> in which case it doesn't matter because no events will be recorded.</p>



<a name="163099936"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/event%20filter%20/%20level%20of%20detail/near/163099936" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/event.20filter.20.2F.20level.20of.20detail.html#163099936">(Apr 11 2019 at 13:40)</a>:</h4>
<p>Ah, okay, that sounds better. Though I still half expect that the cost of option.is_none() might be lower than some set of bit operations for each event</p>



<a name="163099979"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/event%20filter%20/%20level%20of%20detail/near/163099979" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/event.20filter.20.2F.20level.20of.20detail.html#163099979">(Apr 11 2019 at 13:40)</a>:</h4>
<p>Definitely something to test</p>



<a name="163100311"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/event%20filter%20/%20level%20of%20detail/near/163100311" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mw <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/event.20filter.20.2F.20level.20of.20detail.html#163100311">(Apr 11 2019 at 13:44)</a>:</h4>
<p>It might well be that the optimization is not worth it but the idea is to replace</p>
<div class="codehilite"><pre><span></span><span class="k">if</span><span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nb">Some</span><span class="p">(</span><span class="k">ref</span><span class="w"> </span><span class="n">profiler</span><span class="p">)</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">xyz</span><span class="p">.</span><span class="n">profiler</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">   </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">profiler</span><span class="p">.</span><span class="n">filter_mask</span><span class="w"> </span><span class="o">&amp;</span><span class="w"> </span><span class="n">SOME_EVENT</span><span class="p">)</span><span class="w"> </span><span class="o">!=</span><span class="w"> </span><span class="mi">0</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">      </span><span class="n">profiler</span><span class="p">.</span><span class="n">record_some_event</span><span class="p">(...);</span><span class="w"></span>
<span class="w">   </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</pre></div>


<p>with</p>
<div class="codehilite"><pre><span></span><span class="w">   </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">xyz</span><span class="p">.</span><span class="n">profiler</span><span class="p">.</span><span class="n">filter_mask</span><span class="w"> </span><span class="o">&amp;</span><span class="w"> </span><span class="n">SOME_EVENT</span><span class="p">)</span><span class="w"> </span><span class="o">!=</span><span class="w"> </span><span class="mi">0</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">      </span><span class="n">profiler</span><span class="p">.</span><span class="n">record_some_event</span><span class="p">(...);</span><span class="w"></span>
<span class="w">   </span><span class="p">}</span><span class="w"></span>
</pre></div>


<p>and set <code>filter_mask</code> to <code>0</code> when the profiler is disabled completely.</p>



<a name="163100527"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/event%20filter%20/%20level%20of%20detail/near/163100527" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mw <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/event.20filter.20.2F.20level.20of.20detail.html#163100527">(Apr 11 2019 at 13:47)</a>:</h4>
<p>it's probably not something we'd have to do in the initial implementation of event filtering <code>:)</code></p>



<a name="163100643"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/event%20filter%20/%20level%20of%20detail/near/163100643" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/event.20filter.20.2F.20level.20of.20detail.html#163100643">(Apr 11 2019 at 13:48)</a>:</h4>
<p>I would indeed be interested if that would be slower (technically, CPU etc could optimize if filter_mask is 0) and the &amp; is quite cheap these days...</p>



<a name="163100694"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/event%20filter%20/%20level%20of%20detail/near/163100694" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mw <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/event.20filter.20.2F.20level.20of.20detail.html#163100694">(Apr 11 2019 at 13:49)</a>:</h4>
<p>I suspect it not to make much of a difference</p>



<a name="163100718"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/event%20filter%20/%20level%20of%20detail/near/163100718" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mw <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/event.20filter.20.2F.20level.20of.20detail.html#163100718">(Apr 11 2019 at 13:49)</a>:</h4>
<p>then again, doing an <code>if</code> that always evaluates to <code>true</code> is cheap too these days</p>



<a name="163100813"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/event%20filter%20/%20level%20of%20detail/near/163100813" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mw <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/event.20filter.20.2F.20level.20of.20detail.html#163100813">(Apr 11 2019 at 13:50)</a>:</h4>
<p>so maybe I'm trying to be a bit too clever here</p>



<a name="163100843"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/event%20filter%20/%20level%20of%20detail/near/163100843" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/event.20filter.20.2F.20level.20of.20detail.html#163100843">(Apr 11 2019 at 13:50)</a>:</h4>
<p>eh, at least the code will be a bit clearer</p>



<a name="163100885"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/event%20filter%20/%20level%20of%20detail/near/163100885" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mw <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/event.20filter.20.2F.20level.20of.20detail.html#163100885">(Apr 11 2019 at 13:51)</a>:</h4>
<p>yes</p>



<a name="163100898"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/event%20filter%20/%20level%20of%20detail/near/163100898" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mw <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/event.20filter.20.2F.20level.20of.20detail.html#163100898">(Apr 11 2019 at 13:51)</a>:</h4>
<p>that might be more important</p>



<a name="163101424"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/event%20filter%20/%20level%20of%20detail/near/163101424" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mw <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/event.20filter.20.2F.20level.20of.20detail.html#163101424">(Apr 11 2019 at 13:57)</a>:</h4>
<p>one thing I do suggest doing in the first implementation is storing the filter_mask next to the <code>Option&lt;Arc&lt;SelfProfiler&gt;&gt;</code> instead of in <code>SelfProfiler</code> itself. That way the filtering can be done without having to dereference the pointer, leading to better cache behaviour</p>



<a name="163101732"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/event%20filter%20/%20level%20of%20detail/near/163101732" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mw <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/event.20filter.20.2F.20level.20of.20detail.html#163101732">(Apr 11 2019 at 14:00)</a>:</h4>
<p>or in other words, split <code>SelfProfiler</code> into something like </p>
<div class="codehilite"><pre><span></span><span class="k">struct</span> <span class="nc">SelfProfilerInternal</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="p">...</span><span class="w"> </span><span class="n">stuff</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="cp">#[derive(Clone, Send, Sync)]</span><span class="w"></span>
<span class="k">pub</span><span class="w"> </span><span class="k">struct</span> <span class="nc">SelfProfiler</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">event_filter_mask</span>: <span class="kt">u32</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="n">internal</span>: <span class="nb">Option</span><span class="o">&lt;</span><span class="n">Arc</span><span class="o">&lt;</span><span class="n">SelfProfilerInternal</span><span class="o">&gt;&gt;</span><span class="p">,</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</pre></div>



<a name="163102798"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/event%20filter%20/%20level%20of%20detail/near/163102798" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/event.20filter.20.2F.20level.20of.20detail.html#163102798">(Apr 11 2019 at 14:11)</a>:</h4>
<p>hm, I'd expect either to be about equally cached</p>



<a name="163103786"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/event%20filter%20/%20level%20of%20detail/near/163103786" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mw <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/event.20filter.20.2F.20level.20of.20detail.html#163103786">(Apr 11 2019 at 14:21)</a>:</h4>
<p>another thing that I'd like to have numbers on :)</p>



<a name="163458313"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/event%20filter%20/%20level%20of%20detail/near/163458313" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mw <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/event.20filter.20.2F.20level.20of.20detail.html#163458313">(Apr 16 2019 at 10:51)</a>:</h4>
<p>So, I actually ran some perf tests here: <a href="https://github.com/rust-lang/rust/pull/59915" target="_blank" title="https://github.com/rust-lang/rust/pull/59915">https://github.com/rust-lang/rust/pull/59915</a></p>



<a name="163458338"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/event%20filter%20/%20level%20of%20detail/near/163458338" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mw <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/event.20filter.20.2F.20level.20of.20detail.html#163458338">(Apr 16 2019 at 10:52)</a>:</h4>
<p>but the numbers are not very reliable because there are also other changes in there that might affect performance</p>



<a name="163458423"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/event%20filter%20/%20level%20of%20detail/near/163458423" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mw <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/event.20filter.20.2F.20level.20of.20detail.html#163458423">(Apr 16 2019 at 10:53)</a>:</h4>
<p>anyway, filtering itself is very helpful in keeping overhead low: <a href="https://perf.rust-lang.org/compare.html?start=99da733f7f38ce8fe68453e859b7ac96bf7caa0f&amp;end=30ce13219eef2589a769b5d694bdc1c0aec0befc" target="_blank" title="https://perf.rust-lang.org/compare.html?start=99da733f7f38ce8fe68453e859b7ac96bf7caa0f&amp;end=30ce13219eef2589a769b5d694bdc1c0aec0befc">https://perf.rust-lang.org/compare.html?start=99da733f7f38ce8fe68453e859b7ac96bf7caa0f&amp;end=30ce13219eef2589a769b5d694bdc1c0aec0befc</a></p>



<a name="163458596"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/event%20filter%20/%20level%20of%20detail/near/163458596" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mw <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/event.20filter.20.2F.20level.20of.20detail.html#163458596">(Apr 16 2019 at 10:56)</a>:</h4>
<p><span class="user-mention" data-user-id="125250">@Wesley Wiser</span>, <span class="user-mention" data-user-id="116122">@simulacrum</span>: how would you do the commandline interface for this? one option is to do it like the PR does:</p>
<ul>
<li>have a <code>-Zself-profile</code> flag for enabling self-profiling and a separate flag (<code>-Zself-profile-event-filter</code> or something like that) that specifies which events get recorded.</li>
</ul>



<a name="163458648"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/event%20filter%20/%20level%20of%20detail/near/163458648" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mw <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/event.20filter.20.2F.20level.20of.20detail.html#163458648">(Apr 16 2019 at 10:57)</a>:</h4>
<p>another option would be to </p>
<ul>
<li>have just one <code>-Zself-profile</code> flag that takes the events to record as an argument</li>
</ul>



<a name="163458738"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/event%20filter%20/%20level%20of%20detail/near/163458738" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mw <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/event.20filter.20.2F.20level.20of.20detail.html#163458738">(Apr 16 2019 at 10:59)</a>:</h4>
<p>I'd prefer the second option but then we'd have no way to specify the directory to store the profiling data in</p>



<a name="163468193"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/event%20filter%20/%20level%20of%20detail/near/163468193" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/event.20filter.20.2F.20level.20of.20detail.html#163468193">(Apr 16 2019 at 13:20)</a>:</h4>
<p>I'd like to have a "sensible default" which provides a useful set of events but doesn't have too much overhead. This would be the flag we'd use to get performance bug reports from users. I think having the ability to tweak the events captured is also a good idea so I'd propose something like this:</p>
<ul>
<li><code>-Z self-profile</code> records the events we deem useful and places the output files in the working directory.</li>
<li><code>-Z self-profile dir</code> records the events we deem useful and places the output files in the specified folder (creating it if it doesn't exist).</li>
<li><code>-Z self-profile -Z self-profile-event-filter filter</code> records the events matched by the filter and places the output files in the working directory.</li>
<li><code>-Z self-profile dir -Z self-profile-event-filter filter</code> records the events matched by the filter and places the output files in the specified folder (creating it if it doesn't exist)</li>
</ul>



<a name="163541952"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/event%20filter%20/%20level%20of%20detail/near/163541952" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mw <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/event.20filter.20.2F.20level.20of.20detail.html#163541952">(Apr 17 2019 at 08:37)</a>:</h4>
<p>that makes sense to me. I'll update the event filter PR later. <span class="user-mention" data-user-id="116122">@simulacrum</span>, I imagine that <code>perf.rlo</code> will want the ability to specify the output directory right from the beginning, right?</p>



<a name="163542080"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/event%20filter%20/%20level%20of%20detail/near/163542080" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mw <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/event.20filter.20.2F.20level.20of.20detail.html#163542080">(Apr 17 2019 at 08:39)</a>:</h4>
<p>(side note: it would make sense to write data like this to a ram-disk)</p>



<a name="163554541"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/event%20filter%20/%20level%20of%20detail/near/163554541" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/event.20filter.20.2F.20level.20of.20detail.html#163554541">(Apr 17 2019 at 12:13)</a>:</h4>
<p><span class="user-mention" data-user-id="124287">@mw</span> I don't think perf cares too much if the default is working directory</p>



<a name="163554545"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/event%20filter%20/%20level%20of%20detail/near/163554545" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/event.20filter.20.2F.20level.20of.20detail.html#163554545">(Apr 17 2019 at 12:13)</a>:</h4>
<p>(or like /tmp)</p>



<a name="163554558"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/event%20filter%20/%20level%20of%20detail/near/163554558" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/event.20filter.20.2F.20level.20of.20detail.html#163554558">(Apr 17 2019 at 12:13)</a>:</h4>
<p>so long as the filename is either settable or relatively obvious we should be fine</p>



<a name="163557886"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/event%20filter%20/%20level%20of%20detail/near/163557886" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mw <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/event.20filter.20.2F.20level.20of.20detail.html#163557886">(Apr 17 2019 at 13:05)</a>:</h4>
<p>OK, good to know.</p>



<a name="163560947"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/event%20filter%20/%20level%20of%20detail/near/163560947" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/event.20filter.20.2F.20level.20of.20detail.html#163560947">(Apr 17 2019 at 13:39)</a>:</h4>
<p><span class="user-mention" data-user-id="124287">@mw</span> fwiw here's how the current profilers are integrated: <a href="https://github.com/rust-lang-nursery/rustc-perf/blob/master/collector/src/bin/rustc-perf-collector/execute.rs#L476" target="_blank" title="https://github.com/rust-lang-nursery/rustc-perf/blob/master/collector/src/bin/rustc-perf-collector/execute.rs#L476">https://github.com/rust-lang-nursery/rustc-perf/blob/master/collector/src/bin/rustc-perf-collector/execute.rs#L476</a> and <a href="https://github.com/rust-lang-nursery/rustc-perf/blob/master/collector/src/bin/rustc-fake.rs#L18" target="_blank" title="https://github.com/rust-lang-nursery/rustc-perf/blob/master/collector/src/bin/rustc-fake.rs#L18">https://github.com/rust-lang-nursery/rustc-perf/blob/master/collector/src/bin/rustc-fake.rs#L18</a></p>



<a name="163560968"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/event%20filter%20/%20level%20of%20detail/near/163560968" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/event.20filter.20.2F.20level.20of.20detail.html#163560968">(Apr 17 2019 at 13:39)</a>:</h4>
<p>so something loosely similar would probably be wanted</p>



<a name="163562396"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/event%20filter%20/%20level%20of%20detail/near/163562396" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/event.20filter.20.2F.20level.20of.20detail.html#163562396">(Apr 17 2019 at 13:54)</a>:</h4>
<p>What kind of output would be easiest for <code>rustc-perf</code> to interpret? Json, csv, something else?</p>



<a name="163562529"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/event%20filter%20/%20level%20of%20detail/near/163562529" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/event.20filter.20.2F.20level.20of.20detail.html#163562529">(Apr 17 2019 at 13:55)</a>:</h4>
<p>I'm working on the analysis tool and looking to add machine readable output for collection</p>



<a name="163563681"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/event%20filter%20/%20level%20of%20detail/near/163563681" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/event.20filter.20.2F.20level.20of.20detail.html#163563681">(Apr 17 2019 at 14:07)</a>:</h4>
<p><span class="user-mention" data-user-id="125250">@Wesley Wiser</span> Probably JSON? We already emit it so the necessary parts are there</p>



<a name="163563743"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/event%20filter%20/%20level%20of%20detail/near/163563743" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/event.20filter.20.2F.20level.20of.20detail.html#163563743">(Apr 17 2019 at 14:08)</a>:</h4>
<p>but doesn't matter all that much since IIRC we'll be using a library to load the data anyway</p>



<a name="163563763"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/event%20filter%20/%20level%20of%20detail/near/163563763" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/event.20filter.20.2F.20level.20of.20detail.html#163563763">(Apr 17 2019 at 14:08)</a>:</h4>
<p>Ok. Easy enough</p>



<a name="163563831"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/event%20filter%20/%20level%20of%20detail/near/163563831" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/event.20filter.20.2F.20level.20of.20detail.html#163563831">(Apr 17 2019 at 14:09)</a>:</h4>
<p>Is there a prefered encoding for <code>Duration</code>s? I was thinking of outputting nanoseconds</p>



<a name="163563849"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/event%20filter%20/%20level%20of%20detail/near/163563849" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/event.20filter.20.2F.20level.20of.20detail.html#163563849">(Apr 17 2019 at 14:09)</a>:</h4>
<p>That seems reasonable -- what does Serde serialize them as?</p>



<a name="163563945"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/event%20filter%20/%20level%20of%20detail/near/163563945" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/event.20filter.20.2F.20level.20of.20detail.html#163563945">(Apr 17 2019 at 14:10)</a>:</h4>
<p><a href="https://github.com/serde-rs/serde/blob/master/serde/src/ser/impls.rs#L589" target="_blank" title="https://github.com/serde-rs/serde/blob/master/serde/src/ser/impls.rs#L589">https://github.com/serde-rs/serde/blob/master/serde/src/ser/impls.rs#L589</a></p>



<a name="163563996"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/event%20filter%20/%20level%20of%20detail/near/163563996" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/event.20filter.20.2F.20level.20of.20detail.html#163563996">(Apr 17 2019 at 14:11)</a>:</h4>
<p>I'll just serde on our end so it will match up</p>



<a name="163564024"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/event%20filter%20/%20level%20of%20detail/near/163564024" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/event.20filter.20.2F.20level.20of.20detail.html#163564024">(Apr 17 2019 at 14:11)</a>:</h4>
<p>Hm, interestingly, nanoseconds are somewhat not lossless to convert back it seems</p>



<a name="163564042"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/event%20filter%20/%20level%20of%20detail/near/163564042" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/event.20filter.20.2F.20level.20of.20detail.html#163564042">(Apr 17 2019 at 14:11)</a>:</h4>
<p>well, needs work, anyway</p>



<a name="163566734"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/event%20filter%20/%20level%20of%20detail/near/163566734" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/event.20filter.20.2F.20level.20of.20detail.html#163566734">(Apr 17 2019 at 14:40)</a>:</h4>
<p><span class="user-mention" data-user-id="125250">@Wesley Wiser</span> Duration::new takes u32 for nanoseconds but duration can store up to u128 nanoseconds it seems</p>



<a name="163566918"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/event%20filter%20/%20level%20of%20detail/near/163566918" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/event.20filter.20.2F.20level.20of.20detail.html#163566918">(Apr 17 2019 at 14:42)</a>:</h4>
<p>Oh ok. It looks like serde calls the <code>Duration::new(secs, nanos)</code> ctor so that shouldn't be an issue<br>
<a href="https://github.com/serde-rs/serde/blob/79a20e9e33a7cdb68d32cd990b638ce5357230d6/serde/src/de/impls.rs#L1921" target="_blank" title="https://github.com/serde-rs/serde/blob/79a20e9e33a7cdb68d32cd990b638ce5357230d6/serde/src/de/impls.rs#L1921">https://github.com/serde-rs/serde/blob/79a20e9e33a7cdb68d32cd990b638ce5357230d6/serde/src/de/impls.rs#L1921</a></p>



<a name="163567102"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/event%20filter%20/%20level%20of%20detail/near/163567102" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/event.20filter.20.2F.20level.20of.20detail.html#163567102">(Apr 17 2019 at 14:44)</a>:</h4>
<p>yeah, seems fine because of the seconds part I think</p>



<a name="163567253"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/event%20filter%20/%20level%20of%20detail/near/163567253" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/event.20filter.20.2F.20level.20of.20detail.html#163567253">(Apr 17 2019 at 14:46)</a>:</h4>
<p>Yeah, <code>nanos</code> is only used for storing fractional seconds and <code>2^32 -1 ns</code> is ~4 seconds so there shouldn't be any issue there.</p>



<a name="163567490"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/event%20filter%20/%20level%20of%20detail/near/163567490" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/event.20filter.20.2F.20level.20of.20detail.html#163567490">(Apr 17 2019 at 14:48)</a>:</h4>
<p>sounds good</p>



<a name="163614755"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187831-t-compiler/wg-self-profile/topic/event%20filter%20/%20level%20of%20detail/near/163614755" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/187831-t-compiler/wg-self-profile/topic/event.20filter.20.2F.20level.20of.20detail.html#163614755">(Apr 18 2019 at 01:10)</a>:</h4>
<p>PR for the summarization tool is up: <a href="https://github.com/rust-lang/measureme/pull/17" target="_blank" title="https://github.com/rust-lang/measureme/pull/17">https://github.com/rust-lang/measureme/pull/17</a></p>
<p>It also includes a <code>--json</code> flag to have it generate a json version of the analysis. Some sample output:</p>
<div class="codehilite"><pre><span></span><span class="p">{</span>
    <span class="nt">&quot;query_data&quot;</span><span class="p">:</span> <span class="p">[</span>
        <span class="p">{</span>
            <span class="nt">&quot;label&quot;</span><span class="p">:</span> <span class="s2">&quot;codegen 2i9de11lfqzk0ltu&quot;</span><span class="p">,</span>
            <span class="nt">&quot;self_time&quot;</span><span class="p">:</span> <span class="p">{</span>
                <span class="nt">&quot;secs&quot;</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
                <span class="nt">&quot;nanos&quot;</span><span class="p">:</span> <span class="mi">922041</span>
            <span class="p">},</span>
            <span class="nt">&quot;number_of_cache_misses&quot;</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
            <span class="nt">&quot;number_of_cache_hits&quot;</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
            <span class="nt">&quot;invocation_count&quot;</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
            <span class="nt">&quot;blocked_time&quot;</span><span class="p">:</span> <span class="p">{</span>
                <span class="nt">&quot;secs&quot;</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
                <span class="nt">&quot;nanos&quot;</span><span class="p">:</span> <span class="mi">0</span>
            <span class="p">},</span>
            <span class="nt">&quot;incremental_load_time&quot;</span><span class="p">:</span> <span class="p">{</span>
                <span class="nt">&quot;secs&quot;</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
                <span class="nt">&quot;nanos&quot;</span><span class="p">:</span> <span class="mi">0</span>
            <span class="p">}</span>
        <span class="p">},</span>
        <span class="p">{</span>
            <span class="nt">&quot;label&quot;</span><span class="p">:</span> <span class="s2">&quot;CrateHash&quot;</span><span class="p">,</span>
            <span class="nt">&quot;self_time&quot;</span><span class="p">:</span> <span class="p">{</span>
                <span class="nt">&quot;secs&quot;</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
                <span class="nt">&quot;nanos&quot;</span><span class="p">:</span> <span class="mi">21245</span>
            <span class="p">},</span>
            <span class="nt">&quot;number_of_cache_misses&quot;</span><span class="p">:</span> <span class="mi">20</span><span class="p">,</span>
            <span class="nt">&quot;number_of_cache_hits&quot;</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
            <span class="nt">&quot;invocation_count&quot;</span><span class="p">:</span> <span class="mi">21</span><span class="p">,</span>
            <span class="nt">&quot;blocked_time&quot;</span><span class="p">:</span> <span class="p">{</span>
                <span class="nt">&quot;secs&quot;</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
                <span class="nt">&quot;nanos&quot;</span><span class="p">:</span> <span class="mi">0</span>
            <span class="p">},</span>
            <span class="nt">&quot;incremental_load_time&quot;</span><span class="p">:</span> <span class="p">{</span>
                <span class="nt">&quot;secs&quot;</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
                <span class="nt">&quot;nanos&quot;</span><span class="p">:</span> <span class="mi">0</span>
            <span class="p">}</span>
        <span class="p">}</span>
    <span class="p">],</span>
    <span class="nt">&quot;total_time&quot;</span><span class="p">:</span> <span class="p">{</span>
        <span class="nt">&quot;secs&quot;</span><span class="p">:</span> <span class="mi">13</span><span class="p">,</span>
        <span class="nt">&quot;nanos&quot;</span><span class="p">:</span> <span class="mi">351586715</span>
    <span class="p">}</span>
</pre></div>


<p>cc <span class="user-mention" data-user-id="124287">@mw</span> <span class="user-mention" data-user-id="116122">@simulacrum</span></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>